package com.zl.tby.screen.controller;

import com.zl.tby.core.base.util.Pg;
import com.zl.tby.core.common.R;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.core.handle.MethodType;
import org.noear.solon.validation.annotation.Valid;

import java.util.List;
import java.util.Map;

/**
 * @author changpeng
 * @version 1.0
 * @since 2024/11/8 14:36
 */
@Valid
@Controller
@Mapping("/common_screen")
@Slf4j
public class TbyCommonScreenController {
    @Mapping(value = "/xiaoban", method = MethodType.GET)
    public R<Map<String, Object>> xiaoban(String point) {
        try {
            List<Map<String, Object>> list = Pg.queryXiaoban(point);
            return R.ok(list != null && list.size() > 0 ? list.get(0) : null);
        } catch (Exception ex) {
            ex.printStackTrace();
            return R.ok(null);
        }
    }

    @Mapping(value = "/bj", method = MethodType.GET)
    public R<?> bj() {
        try {
            return R.ok(Pg.queryBj());
        } catch (Exception ex) {
            log.error("查询边界异常", ex);
            return R.ok("");
        }
    }
}
